<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var a = 1;
        var a = 2; //1.var可以重复声明，let不可以
        console.log(a);
        let b = 1;
        // let b = 2; //报错
        console.log(b);

        //2.let是块作用域 （全局，局部，eval，块）
        {
            let girl = 'cxy';
            var girl2 = 'cxy2'
        }

       // console.log(girl); //报错 girl未定义
        console.log(girl2); 

        //3. let没有变量提升
        console.log(boy); //undefined
       // console.log(boy2); //报错
        var boy = 'lzx'
        let boy2 = 'lzx2'

        //4. let不影响作用域链
        {
            let school = 'atgg'
            function fn() {
                console.log(school);
            }
            fn();
        }
    </script>
</body>
</html>